<template>
    <div class="box">
        <van-search v-model="value" @focus="onFocus" @blur="onBlur" shape="round" placeholder="搜索" />
        <nav v-if="show">
            <div class="title">全部</div>
            <van-collapse v-model="activeNames">
            <van-checkbox-group v-model="result">
                <van-collapse-item name="1">
                    <template #title>
                        <div class="top">山东艾克瑞特教育科技有限公司 <span>(1)</span></div>
                    </template>
                    <ul>
                        <li>
                            <van-checkbox name="a">
                                自定义图标
                                <template #icon="props">
                                    <img class="img-icon" :src="props.checked ? 'img/xuanzhong@2x.png' : 'img/weixuanzhong@2x.png'" />
                                </template>
                                </van-checkbox>
                        </li>
                    </ul>
                </van-collapse-item>
            </van-checkbox-group>
            </van-collapse>
        </nav>

        <nav v-else>
            <van-checkbox-group v-model="result">
                <ul>
                    <li>
                        <van-checkbox name="a">
                            自定义图标
                            <template #icon="props">
                                <img class="img-icon" :src="props.checked ? 'img/xuanzhong@2x.png' : 'img/weixuanzhong@2x.png'" />
                            </template>
                            </van-checkbox>
                    </li>
                </ul> 
            </van-checkbox-group>
        </nav>
        <!-- 底部按钮 -->
        <footer>
            <button>确定</button>
        </footer>
    </div>
</template>
<script>
export default {
    data() {
        return {
            value:'',
            activeNames:[],
            result: ['a'],
            show:true
        }
    },
    methods: {
        onFocus(){
            this.show = false;
        },
        onBlur(){
            this.show = true;
        }
    },
}
</script>
<style lang="scss" scoped>
    footer{
        padding: 0 0.24rem 0.24rem;
        box-sizing: border-box;
        background: white;
        button{
            width: 100%;
            height: 0.84rem;
            background: #2E9EFF;
            font-size: 0.33rem;
            font-family: PingFang SC;
            font-weight: bold;
            color: #FFFFFF;
            border: none;
            box-shadow: 0.01rem 0.12rem 0.12rem 0.02rem rgba(4, 111, 204, 0.07);
            border-radius: 0.08rem;
        }
    }
    nav{
        flex: 1;
        overflow: scroll;
        background: white;
    }
    .box{
         min-height: 100%;
        background: #F7F9FA;
        display: flex;
        flex-direction: column;
    }
    .title{
        padding: 0.2rem 0.2rem;
        box-sizing: border-box;      
        font-size: 0.24rem;
        font-family: PingFang SC;
        font-weight: bold;
        color: #9A9A9A;
        background:#F7F9FA;
    }
    .top{
        span{
            color: #9A9A9A;
        }
    }
    .img-icon{
        width: 0.24rem;
        height: 0.24rem;
    }
    ul{
        padding: 0 0.25rem;
        box-sizing: border-box;
        li{
            display: flex;
            background: white;
            align-items: center;
            padding-bottom: 0.2rem;
            border-bottom: 0.01rem solid #eeeeee;
            justify-content: space-between;
            font-size: 0.28rem;
            .left{
                font-size: 0.28rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #343434;
            }
            .right{
                display: flex;
                align-items: center;
                .num{
                    font-size: 0.28rem;
                    font-family: PingFang SC;
                    font-weight: 400;
                    color: #9A9A9A;
                    padding-right: 0.2rem;
                    box-sizing: border-box;
                    border-right: 0.01rem solid #eee;
                }
                .under{
                    display: flex;
                    align-items: center;
                    margin-left: 0.2rem;
                    img{
                        width: 0.27rem;
                        height: 0.25rem;
                    }
                    span{            
                        font-size: 0.28rem;
                        font-family: PingFang SC;
                        font-weight: 400;
                        color: #2A9CFF;
                    }
                }
            }
        }
    }
</style>